JS non-null & Optional Chaining
describe_the_problem
// 👇️ optional chaining (?.)
inputRef.current?.focus();
// 👇️ using non-null (!) assertion
inputRef.current!.focus();
Credits
- [link](https://bobbyhadz.com/blog/react-useref-object-is-possibly-null#:~:text=The "Object is possibly null" error is caused,whose.current property is initialized to the passed argument.)